
package com.wthink.card.models;


public class Utils {
	
	public static final int OS_TICKS_PER_SEC = 1000;
	public static final boolean XM_BUS = true;
	public static final String updateFileAPK = "/mnt/internal_sd/upgrade_0/";
	public static int WAIT_SECOND = 1;

	public static long OSTimeGet() {
		return System.currentTimeMillis();
	}

	public static void sleep(int iTime) {
		try {
			Thread.sleep(iTime);
		} catch(Exception e) {
			;
		}
	}

	public static int byteArrayInt(byte[] b) {
		int n = 0;
		byte tmp;
			tmp = b[1];
			n += (tmp & 0xff) << (8 * 0);
			tmp = b[0];
			n += (tmp & 0xff) << (8 * 1);
		return n;
	}

	public static String byteArrayToSring(byte[] b){
		String n="";
		byte tmp;
		for(int i=0;i<8;i++){
			tmp=b[i];
			n+=toBinaryString(tmp&0xff);
		}
		return n;
	}

	public static String toBinaryString(long num) {		//10->2
		char[] chs = new char[8];
		for(int i = 0; i < 8; i++) {
			chs[8 - 1 - i] = (char)(((num >> i) & 1) + '0');
		}
		return new String(chs);
	}

	/**
	 * byte[]תString
	 * @param b
	 * @return
	 */
	public static String Bytes2HexString(byte[] b) {
		String ret = "";
		for (int i = b.length-1; i >= 0; i--) {
			String hex = Integer.toHexString(b[i] & 0xFF);
			if (hex.length() == 1) {
				hex = '0' + hex;
			}
			ret += hex.toUpperCase();
		}
		return ret;
	}
}

